import { RankBaseItem } from "./RankBaseItem";
import { GTextFormat } from "../../../common/GTextFormat";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { TToplist } from "../../../../Message/Db/Tables/TToplist";
import { EToplistType } from "../../../../Message/Public/EToplistType";
import { Language } from "../../../../extend/language/Language";
import { RemainTimeTool } from "../award/RemainTimeTool";
import { EDifficultyOption } from "../../../../Message/Public/EDifficultyOption";
import { ColorConfig } from "../../resource/ColorConfig";
type int = number;
//class OverlordRankItem
    
    export  class OverlordRankItem extends RankBaseItem
    {
        constructor()
        {
            super();
            this.init();
            mouseChildren = false;
            return;
        }

        public get type(): int
        {
            return this._type;
        }

        /* internal  */init(): void
        {
            this._tf = new GTextFormat("", 12, 11661311, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
            this._floorTxt = this.createTextField("", 16, 0, 60, 33, this._tf);
            this._namesTxt = this.createTextField("", 76, 0, 264, 33, this._tf);
            this._timeTxt = this.createTextField("", 340, 0, 90, 33, this._tf);
            var loc1=ObjCreate.createBg(0, 25, 460, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */createTextField(arg1: string, arg2: int, arg3: int, arg4: int, arg5: int, arg6: Object /* flash.text.TextFormat */): Object /* flash.text.TextField */
        {
            var loc1=null;
            (loc1 = new Object /* flash.text.TextField */()).text = arg1;
            loc1.x = arg2;
            loc1.y = arg3;
            loc1.width = arg4;
            loc1.height = arg5;
            loc1.selectable = false;
            loc1.setTextFormat(arg6);
            addChild(loc1);
            return loc1;
        }

        public updateItem(arg1: TToplist, arg2: int): void
        {
            var loc4=0;
            var loc5=null;
            if (arg1 == null) 
            {
                this._floorTxt.text = "";
                this._namesTxt.text = "";
                this._timeTxt.text = "";
                clearBgColor();
                _sEntityId = null;
                return;
            }
            _data = arg1;
            this._type = arg2;
            if (arg2 == EToplistType._EToplistTypeCopyMagicTower || arg2 == EToplistType._ETopListTypeCopyTowerSixty || arg2 == EToplistType._EToplistTypeCopy191) 
            {
                loc4 = _data.valueOne;
                this._floorTxt.text = Language.getStringByParam(32090, loc4);
                this._timeTxt.text = RemainTimeTool.getRemainTimeBySeconds(Math.abs(_data.valueTwo), true, true);
            }
            else if (arg2 == EToplistType._EToplistTypeGuildDefence) 
            {
                loc5 = "";
                if (_data.valueOne != EDifficultyOption._EDifficultyEasy) 
                {
                    if (_data.valueOne != EDifficultyOption._EDifficultyNormal) 
                    {
                        if (_data.valueOne != EDifficultyOption._EDifficultyHard) 
                        {
                            if (_data.valueOne == EDifficultyOption._EDifficultySerious) 
                            {
                                loc5 = Language.getString(32118);
                            }
                        }
                        else 
                        {
                            loc5 = Language.getString(32117);
                        }
                    }
                    else 
                    {
                        loc5 = Language.getString(32116);
                    }
                }
                else 
                {
                    loc5 = Language.getString(32115);
                }
                this._floorTxt.text = loc5;
                this._timeTxt.text = Math.abs(_data.valueTwo) + "";
            }
            this._floorTxt.setTextFormat(this._tf);
            this._timeTxt.setTextFormat(this._tf);
            var loc1=_data.propertyOne;
            var loc2=ColorConfig.instance.getCountryColor(loc1).intColor;
            var loc3=new GTextFormat("", 12, loc2, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
            this._namesTxt.text = _data.entityName;
            this._namesTxt.setTextFormat(loc3);
            initPlayerMenuInfo();
            return;
        }

        /* internal */ /* var */_tf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_floorTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_namesTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_timeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_type: int;
    }
